package com.think.test;

import lombok.Data;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;

import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.summingLong;

/**
 * @author admin
 */
@Data
public class User {
    private String psnName;
    private String deptSort;
    private String deptName;
    private String psnSort;
    private Integer year;
    private Integer month;
    private Integer type;
    private Integer amount;

    public static void main(final String[] args) {
        final ArrayList<User> userArrayList=new ArrayList<>();
        //1.1
        final Map<String,Long> map1=userArrayList.stream().collect(groupingBy(e->e.getDeptName()+"_"+e.getYear()+"_"+e.getMonth()+""+e.getPsnName(), summingLong(User::getAmount)));
        //1.2
        final Map<String,Long> map2=userArrayList.stream().collect(groupingBy(e->e.getDeptName()+"_"+e.getPsnName(), summingLong(User::getAmount)));
        map2.entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)).forEach(e -> System.out.println("部门姓名: "+ e.getKey() +", 天数: "+ e.getValue()));
        //1.3



    }

    public String getPsnName() {
        return this.psnName;
    }

    public void setPsnName(final String psnName) {
        this.psnName = psnName;
    }

    public String getDeptSort() {
        return this.deptSort;
    }

    public void setDeptSort(final String deptSort) {
        this.deptSort = deptSort;
    }

    public String getDeptName() {
        return this.deptName;
    }

    public void setDeptName(final String deptName) {
        this.deptName = deptName;
    }

    public String getPsnSort() {
        return this.psnSort;
    }

    public void setPsnSort(final String psnSort) {
        this.psnSort = psnSort;
    }

    public Integer getYear() {
        return this.year;
    }

    public void setYear(final Integer year) {
        this.year = year;
    }

    public Integer getMonth() {
        return this.month;
    }

    public void setMonth(final Integer month) {
        this.month = month;
    }

    public Integer getType() {
        return this.type;
    }

    public void setType(final Integer type) {
        this.type = type;
    }

    public Integer getAmount() {
        return this.amount;
    }

    public void setAmount(final Integer amount) {
        this.amount = amount;
    }
}
